package com.stuManager.util;

import com.alibaba.fastjson.util.IOUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ReadPostBodyUtil {
    public static  String getPostData(HttpServletRequest request) {
        System.out.println("create body data");
        StringBuilder data = new StringBuilder();
        String line;
        BufferedReader reader;
        try {
            reader = request.getReader();
            while (null != (line = reader.readLine())) {
                System.out.println("line is " + line);
                data.append(line);
            }
        }
        catch  (IOException e) {
            return null;
        }
        return data.toString();
    }
}
